<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Split Button Top Nav</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Split Button Top Nav</h1>

    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><div class="intro">
    <p>
    This example demonstrates how to create a traditional, two-column page layout
    (<a href="../cssgrids/index.html">using Grids</a>) with top navigation rendered like split buttons.
    </p>
</div>

<div class="example newwindow">
    <a href="node-menunav-4-example.html" target="_blank" class="button">
        View Example in New Window
    </a>
</div>

<h2>Setting Up the HTML</h2>
<p>
Begin by including the <a href="../cssgrids/index.html#dependencies">CSS Grids dependencies</a> and grid
markup (this example uses a 2 column version of the
<a href="../cssgrids/cssgrids-fluid.html">Fluid Page Template</a> with a 160px left column).
Add the markup for the menu to the left column of the grid, and the class <code>yui3-skin-sam</code>
to the <code>&#60;body&#62;</code>.
</p>

<p>
The root menu of menus built using the MenuNav Node Plugin can have a verical or horizontal
orientation.  The default orientation for menus is vertical, but can be easily switched to
horizontal by applying a class of <code>yui3-menu-horizontal</code> to the node representing the
root menu's bounding box, as illustrated below:
</p>

<pre class="code prettyprint">&lt;div id=&quot;productsandservices&quot; class=&quot;yui3-menu yui3-menu-horizontal&quot;&gt;&lt;!-- Bounding box --&gt;
    &lt;div class=&quot;yui3-menu-content&quot;&gt;&lt;!-- Content box --&gt;
        &lt;ul&gt;
            &lt;!-- Menu items --&gt;
        &lt;&#x2F;ul&gt;
    &lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;</pre>


<p>
To render each menu label in the horizontal menu as a split button, add the class
<code>yui3-splitbuttonnav</code> to the node representing the root menu's bounding box, as
illustrated below:
</p>

<pre class="code prettyprint">&lt;div id=&quot;menu-1&quot; class=&quot;yui3-menu yui3-menu-horizontal yui3-splitbuttonnav&quot;&gt;&lt;!-- Bounding box --&gt;
    &lt;div class=&quot;yui3-menu-content&quot;&gt;&lt;!-- Content box --&gt;
        &lt;ul&gt;
            &lt;!-- Menu items --&gt;
        &lt;&#x2F;ul&gt;
    &lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;</pre>


<p>
Next, define the markup for each menu label.  Start with a <code>&#60;span&#62;</code> with a class
of <code>yui3-menu-label</code> applied.  Inside the <code>&#60;span&#62;</code>, place two
<code>&#60;a&#62;</code> elements &#151; one for each of the label's two clickable regions.
Each <code>&#60;a&#62;</code> has separate, but related responsibilities:  The first
<code>&#60;a&#62;</code> represents the label's default action.  The second <code>&#60;a&#62;</code>
toggles the display of a submenu whose content contains other options related to, or in the same
category of the default action.  Therefore to configure the first <code>&#60;a&#62;</code>,
simply set its <code>href</code> attribute to any URL.  For the second <code>&#60;a&#62;</code>,
apply a class name of <code>yui3-menu-toggle</code>, and set the value of the <code>href</code>
attribute to the id of the label's corresponding submenu.  Lastly, the text node of the second
<code>&#60;a&#62;</code> should label the contents of its corresponding submenu.
</p>

<pre class="code prettyprint">&lt;div id=&quot;menu-1&quot; class=&quot;yui3-menu yui3-menu-horizontal yui3-splitbuttonnav&quot;&gt;&lt;!-- Bounding box --&gt;
    &lt;div class=&quot;yui3-menu-content&quot;&gt;&lt;!-- Content box --&gt;
        &lt;ul&gt;
            &lt;li&gt;

                &lt;span class=&quot;yui3-menu-label&quot;&gt;&lt;!-- menu label root node --&gt;
                    &lt;a href=&quot;http:&#x2F;&#x2F;answers.yahoo.com&quot;&gt;Answers&lt;&#x2F;a&gt;&lt;!-- menu label default action --&gt;
                    &lt;a href=&quot;#answers-options&quot; class=&quot;yui3-menu-toggle&quot;&gt;Answers Options&lt;&#x2F;a&gt;&lt;!-- menu label submenu toggle --&gt;
                &lt;&#x2F;span&gt;

                &lt;div id=&quot;answers-options&quot; class=&quot;yui3-menu&quot;&gt;
                    &lt;div class=&quot;yui3-menu-content&quot;&gt;
                        &lt;ul&gt;
                            &lt;li class=&quot;yui3-menuitem&quot;&gt;&lt;a class=&quot;yui3-menuitem-content&quot; href=&quot;http:&#x2F;&#x2F;answers.yahoo.com&#x2F;dir&#x2F;&quot;&gt;Answer&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
                            &lt;li class=&quot;yui3-menuitem&quot;&gt;&lt;a class=&quot;yui3-menuitem-content&quot; href=&quot;http:&#x2F;&#x2F;answersonthestreet.yahoo.com&#x2F;&quot;&gt;Answers on the Street&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
                            &lt;li class=&quot;yui3-menuitem&quot;&gt;&lt;a class=&quot;yui3-menuitem-content&quot; href=&quot;http:&#x2F;&#x2F;answers.yahoo.com&#x2F;question&#x2F;;_ylt=Av3Nt22Mr7YNs651NWFv8YUPzKIX;_ylv=3?link=ask&quot;&gt;Ask&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
                            &lt;li class=&quot;yui3-menuitem&quot;&gt;&lt;a class=&quot;yui3-menuitem-content&quot; href=&quot;http:&#x2F;&#x2F;answers.yahoo.com&#x2F;dir&#x2F;;_ylt=Aqp_jJlsYDP7urcq2WGC6HBJxQt.;_ylv=3?link=over&amp;amp;amp;more=y&quot;&gt;Discover&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
                        &lt;&#x2F;ul&gt;
                    &lt;&#x2F;div&gt;
                &lt;&#x2F;div&gt;

            &lt;&#x2F;li&gt;
        &lt;&#x2F;ul&gt;
    &lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;</pre>


<h2>Initializing the Menu</h2>
<p>
With the menu markup in place, retrieve the Node instance representing the root
menu (<code>&#60;div id="productsandservices"&#62;</code>) and call the
<a href="http://yuilibrary.com/yui/docs/api/classes/Node.html#method_plug"><code>plug</code></a>
passing in a reference to the MenuNav Node Plugin.
</p>

<p>
Use the
<a href="http://yuilibrary.com/yui/docs/api/classes/plugin.NodeMenuNav.html#config_autoSubmenuDisplay"><code>autoSubmenuDisplay</code></a>
and <a href="http://yuilibrary.com/yui/docs/api/classes/plugin.NodeMenuNav.html#config_mouseOutHideDelay"><code>mouseOutHideDelay</code></a>
configuration attributes to configure the menu labels to behave like split buttons.  Set the
<code>autoSubmenuDisplay</code> to <code>false</code>, so that each menu label's submenu isn't
made visible until the menu trigger is clicked.  Set the <code>mouseOutHideDelay</code> to
<code>0</code> so that a label's submenu is only hidden when the user mouses down on an area
outside of the submenu.
</p>

<pre class="code prettyprint">&lt;!-- YUI Seed --&gt;
&lt;script src=&quot;..&#x2F;..&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;

&lt;script&gt;
&#x2F;&#x2F;  Call the &quot;use&quot; method, passing in &quot;node-menunav&quot;.  This will load the
&#x2F;&#x2F;  script and CSS for the MenuNav Node Plugin and all of the required
&#x2F;&#x2F;  dependencies.

YUI().use(&#x27;node-menunav&#x27;, function(Y) {

    &#x2F;&#x2F;  Retrieve the Node instance representing the root menu
    &#x2F;&#x2F;  (&lt;div id=&quot;productsandservices&quot;&gt;) and call the &quot;plug&quot; method
    &#x2F;&#x2F;  passing in a reference to the MenuNav Node Plugin.

    var menu = Y.one(&quot;#productsandservices&quot;);

    menu.plug(Y.Plugin.NodeMenuNav, { autoSubmenuDisplay: false, mouseOutHideDelay: 0 });

});
&lt;&#x2F;script&gt;</pre>


<p>
<em>Note:</em> In keeping with the
<a href="http://developer.yahoo.com/performance/">Exceptional Performance</a>
team's recommendation, the script block used to instantiate the menu will be
<a href="http://developer.yahoo.com/performance/rules.html#js_bottom">placed at the bottom of the page</a>.
This not only improves performance, it helps ensure that the DOM subtree of the
element representing the root menu
(<code>&#60;div id="productsandservices"&#62;</code>) is ready to be scripted.
</p>
</div>
        </div>

        <div id="sidebar" class="yui3-u">
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Creating left navigation using the MenuNav Node Plugin.">
                                        <a href="menunav-leftnav.html">Basic Left Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating top navigation using the MenuNav Node Plugin">
                                        <a href="node-menunav-2.html">Basic Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating menu button navigation using the MenuNav Node Plugin">
                                        <a href="node-menunav-3.html">Menu Button Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Creating split button navigation using the MenuNav Node Plugin">
                                        <a href="node-menunav-4.html">Split Button Top Nav</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Adding shadows to submenus of a left nav using the MenuNav Node Plugin">
                                        <a href="node-menunav-5.html">Left Nav with Submenus with Shadows</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Adding rounded corners to submenus of a left nav using the MenuNav Node Plugin">
                                        <a href="node-menunav-6.html">Left Nav With Submenus With Rounded Corners</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Skining a menu built using the MenuNav Node Plugin to look like the menus on Flickr">
                                        <a href="node-menunav-7.html">Skinning Menus Created Using the MenuNav Node Plugin</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            

            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
